from xinference.client import Client

client = Client("http://localhost:9997")

# xinference launch --model-uid whisper-1 --model-name whisper-tiny --model-type audio
# model_uid = client.launch_model(model_uid="whisper-1",model_name="whisper-tiny", model_type="audio")
# whisper-tiny

model = client.get_model("whisper-1")

input_text = "an apple"
with open("voice-test.mp3", "rb") as audio_file:
    print("######## 音频转文本 ########")
    tmp = audio_file.read()
    out = model.transcriptions(tmp)
    print(out['text'])
    print("######## 音频转翻译 ########")
    out = model.translations(tmp)
    print(out['text'])
